package com.hanggold.captcha.util;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.Random;

/**
 * 随机数.
 *
 * @author <a href="mailto:free@hanggold.com">free</a>
 * @date 2021-09-30 08:38
 * @since 1.0.0
 **/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RandomUtil {
    
    private static final Random RANDOM = new Random();
    
    /**
     * [0,max }.
     *
     * @param max 最大值
     * @return int
     */
    public static int randomInt(final int max) {
        return RANDOM.nextInt(max);
    }
    
    /**
     * [min,max }.
     *
     * @param min min
     * @param max max
     * @return int
     */
    public static int randomInt(final int min, final int max) {
        return randomInt(max - min) + min;
    }
}
